﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/MasterPage.Master" AutoEventWireup="true" CodeBehind="AddUser.aspx.cs" Inherits="DrivingCRM.Views.Private.CRM.AddUser" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="banniere" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="nav" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="contenu" runat="server">
    <fieldset style="width:80%;margin:20px;">
        <legend>Ajouter un nouvel utilisateur</legend>
        <table>
            <tr>
                <td align="right">
                    <asp:Label ID="FirstnameLabel" runat="server" AssociatedControlID="Firstname">Prénom:</asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="Firstname" runat="server" Width="270"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="FirstnameRequired" runat="server" 
                        ControlToValidate="Firstname" ErrorMessage="Firstname is required." 
                        ToolTip="Firstname is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="LastnameLabel" runat="server" AssociatedControlID="Lastname">Nom:</asp:Label>
                </td>
                <td align="center">
                    <asp:TextBox ID="Lastname" runat="server" Width="270"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="LastnameRequired" runat="server" 
                        ControlToValidate="Lastname" ErrorMessage="Lastname is required." 
                        ToolTip="Lastname is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <asp:UpdatePanel ID="UP_Date" runat="server">
                <ContentTemplate>
                    <tr>
                        <td align="right">
                            <asp:Label ID="DateOfBirthLabel" runat="server" AssociatedControlID="RDP_DateOfBirth">Date de naissance:</asp:Label>
                        </td>
                        <td align="center">
                            <telerik:RadDatePicker ID="RDP_DateOfBirth" runat="server">
                            </telerik:RadDatePicker>
                        </td>
                    </tr>
                </ContentTemplate>
            </asp:UpdatePanel>
            <tr>
                <td align="right">
                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Nom d'utilisateur:</asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="UserName" runat="server" Width="270"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                        ControlToValidate="UserName" ErrorMessage="User Name is required." 
                        ToolTip="User Name is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Mot de passe:</asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="Password" runat="server" TextMode="Password" Width="270"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 
                        ControlToValidate="Password" ErrorMessage="Password is required." 
                        ToolTip="Password is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="ConfirmPasswordLabel" runat="server" 
                        AssociatedControlID="ConfirmPassword" Width="270">Confirmation:</asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password" Width="270"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" 
                        ControlToValidate="ConfirmPassword" 
                        ErrorMessage="Confirm Password is required." 
                        ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="Email" runat="server" Width="270"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="EmailRequired" runat="server" 
                        ControlToValidate="Email" ErrorMessage="E-mail is required." 
                        ToolTip="E-mail is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="DDL_Question">Question secrète:</asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="DDL_Question" runat="server">
                        <asp:ListItem Text="Quel est le nom de votre premier animal de companie?" Value="Quel est le nom de votre premier animal de companie?" />
                        <asp:ListItem Text="Quel est le nom de jeune fille de votre mère?" Value="Quel est le nom de jeune fille de votre mère?" />
                        <asp:ListItem Text="Quel est le nom de votre première école primaire?" Value="Quel est le nom de votre première école primaire?" />
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer">Réponse:</asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="Answer" runat="server" Width="270"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="AnswerRequired" runat="server" 
                        ControlToValidate="Answer" ErrorMessage="Security answer is required." 
                        ToolTip="Security answer is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <asp:UpdatePanel ID="UP_UserType" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <tr>
                        <td>Type d'utilisateur:</td>
                        <td>
                            <asp:DropDownList ID="DDL_UserType" runat="server" AutoPostBack="true" >
                                <asp:ListItem Text="Client" Value="client" />
                                <asp:ListItem Text="Vendeur" Value="salesman" />
                                <asp:ListItem Text="Intervenant" Value="stakeholder" />
                                <asp:ListItem Text="Administrateur" Value="administrator" />
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <asp:MultiView ID="MV_UserView" runat="server">
                        <asp:View ID="V_Client" runat="server">
                            <tr>
                                <td colspan="2">
                                    <fieldset>
                                        <legend>Adresse</legend>
                                        <table>
                                            <tr>
                                                <td>Numéro:</td>
                                                <td>
                                                    <asp:TextBox ID="Number" runat="server" Width="270"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="NumberRequired" runat="server" 
                                                        ControlToValidate="Number" ErrorMessage="The street number is required." 
                                                        ToolTip="The street Number is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator></td>
                                            </tr>
                                            <tr>
                                                <td>Type de rue:</td>
                                                <td><%--<asp:DropDownList ID="StreetType" runat="server">
                                                        <asp:ListItem Text="Street" Value="Street" />
                                                        <asp:ListItem Text="Avenue" Value="Avenue" />
                                                        <asp:ListItem Text="Boulevard" Value="Boulevard" />
                                                        <asp:ListItem Text="Dead end" Value="Deadend" />
                                                        <asp:ListItem Text="Path" Value="ath" />
                                                    </asp:DropDownList>--%>
                                                    <asp:DropDownList ID="StreetType" runat="server" DataSourceID="DS_StreetTypes" 
                                                        DataTextField="Type" DataValueField="Id">
                                                    </asp:DropDownList>

                                                    <asp:EntityDataSource ID="DS_StreetTypes" runat="server" 
                                                        ConnectionString="name=Model_DrivingCRMContainer" 
                                                        DefaultContainerName="Model_DrivingCRMContainer" EnableFlattening="False" 
                                                        EntitySetName="StreetTypeSet" EntityTypeFilter="StreetType">
                                                    </asp:EntityDataSource>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Nom de la rue:</td>
                                                <td><asp:TextBox ID="StreetName" runat="server" Width="270"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="StreetNameRequired" runat="server" 
                                                        ControlToValidate="StreetName" ErrorMessage="The street name is required." 
                                                        ToolTip="The street name is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator></td>
                                            </tr>
                                            <tr>
                                                <td>Compléments (facultatif):</td>
                                                <td><asp:TextBox ID="Extra" runat="server" Width="270"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td>Code postale (en chiffre uniquement):</td>
                                                <td><asp:TextBox ID="Zipcode" runat="server" Width="270"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="ZipcodeRequired" runat="server" 
                                                        ControlToValidate="Zipcode" ErrorMessage="The zip code is required" 
                                                        ToolTip="The zip code is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator></td>
                                            </tr>
                                            <tr>
                                                <td>Ville:</td>
                                                <td><asp:TextBox ID="City" runat="server" Width="270"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="CityRequired" runat="server" 
                                                        ControlToValidate="City" ErrorMessage="The City is required." 
                                                        ToolTip="The City is required." ValidationGroup="CreateUserWizard_NewUser">*</asp:RequiredFieldValidator></td>
                                            </tr>
                                            <tr>
                                                <td>Cedex (facultatif):</td>
                                                <td><asp:TextBox ID="Cedex" runat="server" Width="270"></asp:TextBox></td>
                                            </tr>
                                        </table>
                                    </fieldset>
                                </td>
                            </tr>
                        </asp:View>
                        <asp:View ID="V_Others" runat="server">
                        </asp:View>
                        <asp:View ID="V_Stakeholder" runat="server">
                            <tr>
                                <td>Permis B (voiture):</td>
                                <td><asp:CheckBox ID="CB_LicenseB" runat="server" /></td>
                            </tr>
                            <tr>
                                <td>Permis A (moto):</td>
                                <td><asp:CheckBox ID="CB_LicenseA" runat="server" /></td>
                            </tr>
                        </asp:View>
                    </asp:MultiView>
                    <asp:MultiView ID="MV_Agency" runat="server">
                        <asp:View ID="V_Admin" runat="server">
                        </asp:View>
                        <asp:View ID="V_NoAdmin" runat="server">
                            <tr>
                                <td>Agence:</td>
                                <td>
                                    <asp:DropDownList ID="DDL_Agencies" runat="server" DataSourceID="DS_Agencies" 
                                        DataTextField="Name" DataValueField="IdAgency">
                                    </asp:DropDownList>

                                    <asp:EntityDataSource ID="DS_Agencies" runat="server" 
                                        ConnectionString="name=Model_DrivingCRMContainer" 
                                        DefaultContainerName="Model_DrivingCRMContainer" EnableFlattening="False" 
                                        EntitySetName="AgencySet" EntityTypeFilter="Agency">
                                    </asp:EntityDataSource>
                                </td>
                            </tr>
                        </asp:View>
                    </asp:MultiView>
                </ContentTemplate>
                <%--<Triggers>
                    <asp:AsyncPostBackTrigger ControlID="DDL_UserType" EventName="SelectedIndexChanged" />
                </Triggers>--%>
            </asp:UpdatePanel>
            <tr>
                <td align="center" colspan="2">
                    <asp:CompareValidator ID="PasswordCompare" runat="server" 
                        ControlToCompare="Password" ControlToValidate="ConfirmPassword" 
                        Display="Dynamic" 
                        ErrorMessage="The Password and Confirmation Password must match." 
                        ValidationGroup="CreateUserWizard_NewUser"></asp:CompareValidator>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2" style="color:Red;">
                    <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td colspan="2"><br /></td>
            </tr>
            <tr>
                <td><asp:Button runat="server" Text="Create User" ID="B_CreateUser" 
                        onclick="B_CreateUser_Click" /></td>
                <td></td>
            </tr>
        </table>
    </fieldset>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="footer" runat="server">
</asp:Content>
